package com.jty.lib_base.api


import com.jty.lib_base.api.ApiService.ApiUrl.RESEARCH_BASE_URL
import com.jty.lib_base.api.ApiService.ApiUrl.ROOM_TOKEN_BASE_URL
import com.jty.lib_base.base.BaseBean
import com.jty.lib_base.data.bean.*
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.*


/**
 * author: zhouyh
 * created on: 2021/5/11 11:24 下午
 * description:
 */
interface ApiService {

    object ApiUrl{

        //服务端根路径
//        const val URL_BASE_DEV  = "http://teacher.dev.wljty.com:12080/"   //测试 url api.iptar.dev.learndar.net
        const val URL_BASE_DEV  = "https://api.iptar.dev.learndar.net/"   //测试 url api.iptar.dev.learndar.net
        const val URL_BASE_PROD  = "https://teacher.wljty.com/"           //生产 url   api.iptar.learndar.net

        const val URL_RESEARCH_DEV  =  "http://teacher.learndar.net"   //教研测试url
        const val URL_RESEARCH_PROD  =  "https://teacher-prod.learndar.net"   //教研生产 url
        const val URL_ROOM_TOKEN  =  "https://api.netless.link"   //声网url

        const val RESEARCH_BASE_URL = "research_base_url"       //教研模块
        const val ROOM_TOKEN_BASE_URL = "room_token_base_url"   //声网


        //切换环境配置
        const val URL_BASE = URL_BASE_DEV
        //const val URL_RESEARCH_BASE = URL_RESEARCH_DEV
    }


    /**
     * 获取阿里云oss临时配置
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/token/ossConf")
    fun getOssConf():Observable<BaseBean<OssBean>>

    /**
     *获取直播token
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/token/getConsoleToken.json")
    fun getRoomToken(@Body requestBody: RequestBody):Observable<BaseBean<RoomTokenBean>>

    /**
     * 获取白板Token
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/token/getRoomUuidAndToken.json")
    fun getRoomUuidAndToken(@Body requestBody: RequestBody):Observable<BaseBean<WhiteboardTokenBean>>

    /**
     * 走声网地址请求
     * 动态获取白板的roomToken
     */
//    @Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + ROOM_TOKEN_BASE_URL)
    @POST("/v5/tokens/rooms/{uuid}")
    fun getWhiteRoomToken(@Path("uuid") uuid:String,@Body requestBody: RequestBody):Observable<String>

    /**
     * 获取Token
     */
    @POST("api/oauth2/token")
    @FormUrlEncoded
    fun getToken(
        @Field("grant_type") grant_type: String,
        @Field("client_id") client_id: String,
        @Field("client_secret") client_secret: String,
        @Field("device_type") device_type: String,
        @Field("username") username: String,
        @Field("password") password: String,
    ):Observable<BaseBean<TokenBean>>

    @POST("/api/mini/teacher/login.json")
    fun login(@Body requestBody: RequestBody):Observable<BaseBean<LoginBean>>

    /**
     * 发送验证码
     */
    @POST("/api/teacher/common/sendMsg.json")
    fun sendMsgCode(@Body requestBody: RequestBody):Observable<BaseBean<String>>

    /**
     * 重置密码
     */
    @POST("/api/mini/teacher/forget.json")
    fun resetPassword(@Body requestBody: RequestBody) : Observable<BaseBean<Any?>>



    /**
     * 教研活动模块接口 与通用接口不一致
     * 所有教研相关接口需要加注解
     * @Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
     */


    /**
     * 教研活动--查询活动列表
     * name 活动主题
     * stageId 学段
     * subjectId 学科
     * state 状态  //状态(1.直播/2.线下/3.预告/4.回放)  0全部
     * tenantId  创建人学校id
     * regionId  区域id
     * teacherId 教师id
     * tabkey  tab标志
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/tra/queryActivity.json")
    fun queryResearchActivity(@Body requestBody: RequestBody):Observable<BaseBean<ResearchActivityListBean>>


    /**
     * 获取教研模块tab数据
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/tra/activity/numInfo.json")
    fun getResearchTabData(@Body requestBody: RequestBody):Observable<BaseBean<List<ResearchTabBean>>>

    /**
     * 教研活动详情
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/tra/getActivity.json")
    fun getResearchActivityDetail(@Body requestBody: RequestBody):Observable<BaseBean<ResearchDetailBean>>

    /**
     * 教研活动笔记获取
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/mini/note/selectTeacherNote.json")
    fun selectTeacherNote(@Body requestBody: RequestBody):Observable<BaseBean<RoomNoteBean>>


    /**
     * 活动报名人列表
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/tra/register/list.json")
    fun getResearchJoinPeople(@Body requestBody: RequestBody):Observable<BaseBean<List<ResearchJoinPeopleBean>>>

    /**
     * 活动报名人列表
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/tra/register.json")
    fun joinResearchActivity(@Body requestBody: RequestBody):Observable<BaseBean<Any>>

    /**
     * 上传教研笔迹
     * activity活动ID
     * pics    图片数组
     *way 录入方式，蓝牙笔书写：write,拍照：photo
     *蓝牙笔书写：write上传模式需要
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/mini/note/uploadNote.json")
    fun uploadResearchNote(@Body requestBody: RequestBody):Observable<BaseBean<Any>>

    /**
     * 分享
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/mini/note/picsToPdf.json")
    fun sharePics(@Body requestBody: RequestBody):Observable<BaseBean<String>>


    /**
     * 清空整个教研活动的笔记
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/mini/note/delete.json")
    fun deleteResearchNote(@Body requestBody: RequestBody):Observable<BaseBean<Any>>

    /**
     * 查询直播状态
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("/api/teacher/tra/activity/state.json")
    fun getLiveState(@Body requestBody: RequestBody):Observable<BaseBean<LiveStateBean>>


    /**
     * 退出登录
     */
    @GET("user/logout/json")
    fun logout(): Observable<BaseBean<Any?>>



    /**
     * 获取用户信息
     */
    @POST("/api/mini/teacher/teacherInfo.json")
    fun getUserInfo():Observable<BaseBean<UserInfoBean>>

    /**
     * 修改用户个人信息
     */
    @POST("/api/mini/teacher/updateTeacherInfo.json")
    fun modifyUserInfo(@Body requestBody: RequestBody)
            :Observable<BaseBean<Any?>>

    /**
     * 修改手机号码
     */
    @POST("/api/mini/teacher/updateMobile.json")
    fun modifyPhone(@Body requestBody: RequestBody)
            :Observable<BaseBean<Any?>>

    /**
     * 根据学段获取学科
     */
    @POST("api/app/user/getSchoolPhaseSubjectList")
    fun getSchoolPhaseSubjectList(@Body requestBody: RequestBody)
            :Observable<BaseBean<List<UserInfoBean>>>

    /**
     * 学段查询
     */
    @POST("/api/teacher/common/querySection.json")
    fun querySection():Observable<BaseBean<List<SectionBean>>>

    /**
     * 学科查询
     */
    @POST("/api/teacher/common/querySubject.json")
    fun querySubject():Observable<BaseBean<List<SubjectBean>>>

    /**
     * 修改密码
     */
    @POST("/api/mini/teacher/updatePassword.json")
    fun modifyPassword(@Body requestBody: RequestBody)
            :Observable<BaseBean<Any?>>

    /**
     * 获得老师笔
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/pen/getTeacherPen.json")
    fun getTeacherPen()
            :Observable<BaseBean<TeacherPenBean>>


    /**
     * 我的教研笔记
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/note/pageBybookNote.json")
    fun pageBybookNote(@Body requestBody: RequestBody)
            :Observable<BaseBean<PageBybookNoteBean>>

    /**
     * 我的教研笔记整本信息
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/note/bookNoteByTeacherId.json")
    fun bookNoteByTeacherId(@Body requestBody: RequestBody)
            :Observable<BaseBean<List<GridPictureBean>>>

    /**
     * 获取笔记本整本信息
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/note/getNoteTemplateInfo1.json")
    fun getNoteTemplateInfo1(@Body requestBody: RequestBody)
            :Observable<BaseBean<BookNoteBean>>

    /**
     * 我的教研笔记离线上传
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/note/commitTeacherBookNote.json")
    fun commitTeacherBookNote(@Body requestBody: RequestBody)
            :Observable<BaseBean<Any?>>

    /**
     * 我的教研笔记在线上传
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/note/commitTeacherBookNoteOnline.json")
    fun commitTeacherBookNoteOnLine(@Body requestBody: RequestBody)
            :Observable<BaseBean<Any?>>

    /**
     * 教师书写前书写记录确认
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/note/createTeacherWriteRecord.json")
    fun createTeacherWriteRecord(@Body requestBody: RequestBody)
            :Observable<BaseBean<Any?>>

    /**
     * 检查教师连接的mac 并返回上次连接地址
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/pen/checkTeacherMac.json")
    fun checkTeacherMac(@Body requestBody: RequestBody)
            :Observable<BaseBean<CheckTeacherMacBean>>

    /**
     *获取笔记本单页信息
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/note/getOneNoteTemplateInfo.json")
    fun getOneNoteTemplateInfo(@Body requestBody: RequestBody)
            :Observable<BaseBean<GridPictureBean>>



    /**
     * 确认连接- 更新教师笔连接记录
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @POST("api/mini/pen/teacherConfirmConnect.json")
    fun teacherConfirmConnect(@Body requestBody: RequestBody)
            :Observable<BaseBean<Any?>>

    /**
     * 版本信息
     */
    //@Headers(RetrofitUrlManager.DOMAIN_NAME_HEADER + RESEARCH_BASE_URL)
    @GET("api/manager/AppVersion/android/queryLastVersion")
    fun queryLastVersion(@Query("version") version: String)
            :Observable<BaseBean<VersionInfoBean>>

}